home *** CD-ROM | disk | FTP | other *** search
/ Teach Your Children: Road Construction Ahead / Teach Your Children: Road Construction Ahead.iso / pc / rca / road.dxr / 00007_MakeAScene Parent.ls < prev    next >
Encoding:
Text File  |  1996-07-17  |  12.0 KB  |  399 lines

  1. property firstColorSticker, stickerList, firstStickerChan, currentLayer, constrainChan, bgChan, dragChan, dragFlag, placeFlag, maxStickers, placeConstrainFlag, currentBoundRect, printButChannel, stickerSongList, dragStickerCastPos, playList, firstTime, sceneDataString, dataCounter, firstColorBG, currentBG, howManyBGs, bgLocH, bgLocV, grayStickerOffset, firstGrayBG, songList, sandboxChan, printButCover, musicButObject
  2. global gActorList, gTrashObject, gRollAnimButton, gGasGaugeObject, gMenuObject, gAwardsObject, gMusicObject, gCDpath, gFileSep
  3.  
  4. on birth me
  5.   set firstTime to 1
  6.   set constrainChan to 1
  7.   set bgChan to 7
  8.   set sandboxChan to 11
  9.   set firstStickerChan to 16
  10.   set printButChannel to 13
  11.   set maxStickers to 30
  12.   set dragFlag to 0
  13.   set placeFlag to 0
  14.   set dragChan to 48
  15.   set stickerList to []
  16.   set firstColorSticker to the number of cast "Sticker1" - 1
  17.   set grayStickerOffset to the number of cast "BWsticker1" - firstColorSticker - 1
  18.   set firstColorBG to the number of cast "blankScene"
  19.   set firstGrayBG to the number of cast "blankScene.b+w"
  20.   set currentBG to 1 + random(3)
  21.   set howManyBGs to 4
  22.   set bgLocH to 322
  23.   set bgLocV to 213
  24.   set placeConstrainFlag to 0
  25.   set stickerSongList to [9, #x, 5, #x, 2, #x, 3, #x, 7, 4, #x, 6, 1, #x, #x, 8, #x, #x]
  26.   set playList to []
  27.   sort(playList)
  28.   set songCounter to 0
  29.   set songList to ["09FOREMU", "0716MU", "0713MU", "0715MU", "0714MU", "0717MU", "0718MU", "09TEAMMU", "09LADYMU"]
  30.   set printButCover to the number of cast "printCoverMAS"
  31.   return me
  32. end
  33.  
  34. on fixBG me, firstBG
  35.   set the type of sprite bgChan to 1
  36.   set the castNum of sprite bgChan to firstBG + currentBG - 1
  37.   set the locH of sprite bgChan to bgLocH
  38.   set the locV of sprite bgChan to bgLocV
  39.   puppetSprite(bgChan, 1)
  40. end
  41.  
  42. on predraw me
  43.   fixBG(me, firstColorBG)
  44.   fixGasChannel(gGasGaugeObject)
  45.   drawStickers(me, 1)
  46.   puppetStickers(me)
  47.   if the printEnabled of gMenuObject = 0 then
  48.     set the castNum of sprite printButChannel to printButCover
  49.     set the locH of sprite printButChannel to 287
  50.     set the locV of sprite printButChannel to 429
  51.     puppetSprite(printButChannel, 1)
  52.   end if
  53. end
  54.  
  55. on changeBG me
  56.   if count(stickerList) = 0 then
  57.     set currentBG to currentBG + 1
  58.     if currentBG > howManyBGs then
  59.       set currentBG to 1
  60.     end if
  61.     set the castNum of sprite bgChan to firstColorBG + currentBG - 1
  62.     playSound("CHANGEBG")
  63.   end if
  64. end
  65.  
  66. on print me
  67.   if the printEnabled of gMenuObject = 1 then
  68.     clearAllActors()
  69.     unpuppetAll()
  70.     keepSandboxBut(sandboxChan)
  71.     puppetPalette("ScenePal")
  72.     go("Grass")
  73.     set the stageColor to 0
  74.     go(the frame + 1)
  75.     puppetPalette("GrayScenePal", 60)
  76.     updateStage()
  77.     unLoadCast()
  78.     fixBG(me, firstGrayBG)
  79.     fixGasChannel(gGasGaugeObject)
  80.     drawStickers(me, 1, grayStickerOffset)
  81.     puppetStickers(me)
  82.     puppetPalette(0)
  83.     go("MASgray")
  84.     copyScreenRegion(bgChan)
  85.     printBitmap("LineArtTemp")
  86.     resetCastMember()
  87.     donePrinting(me)
  88.   else
  89.     copyScreenRegion(bgChan)
  90.     printBitmap("LineArtTemp")
  91.     resetCastMember()
  92.     showAllActors()
  93.   end if
  94. end
  95.  
  96. on donePrinting me
  97.   clearAllActors()
  98.   unpuppetAll()
  99.   puppetSprite(48, 1)
  100.   puppetPalette("GrayScenePal")
  101.   go("Grass")
  102.   go(the frame + 1)
  103.   set the stageColor to 255
  104.   puppetPalette("ScenePal", 60)
  105.   updateStage()
  106.   puppetPalette(0)
  107.   unLoadCast()
  108.   predraw(me)
  109.   go("MakeAscene")
  110.   puppetSprite(48, 0)
  111. end
  112.  
  113. on puppetStickers me
  114.   repeat with x = 1 to count(stickerList)
  115.     set channel to x + firstStickerChan - 1
  116.     set the ink of sprite channel to 8
  117.     puppetSprite(channel, 1)
  118.   end repeat
  119. end
  120.  
  121. on setup me
  122.   if firstTime then
  123.     set gTrashObject to birth(script "Trashcan Parent")
  124.     set firstTime to 0
  125.   end if
  126.   clearAllActors()
  127.   puppetAll()
  128.   set musicButObject to birth(script "Rollover Anim Button Class", "playSongs( gSceneObject )", 14, 14, 4, "0713VO46", "0713RO46")
  129.   add(gActorList, musicButObject)
  130.   add(gActorList, birth(script "Rollover Anim Button Class", "goMenu( gSceneObject, me )", 11, 11, 5, "RCA-07VO01", "RCA-07RO01"))
  131.   add(gActorList, birth(script "Rollover Anim Button Class", "help( gSceneObject, me )", 12, 12, 11, EMPTY, "RCA-05RO02"))
  132.   if the printEnabled of gMenuObject then
  133.     add(gActorList, birth(script "Rollover Anim Button Class", "print( gSceneObject )", 13, 13, 5, "0713VO03", "0713RO03"))
  134.   end if
  135. end
  136.  
  137. on update me
  138.   if dragFlag = 1 then
  139.     set the locV of sprite dragChan to the mouseV
  140.     set the locH of sprite dragChan to the mouseH
  141.     updateStage()
  142.     if placeFlag = 1 then
  143.       if placeConstrainFlag = 0 then
  144.         if sprite dragChan within bgChan then
  145.           set the rect of sprite constrainChan to currentBoundRect
  146.           updateStage()
  147.           set the constraint of sprite dragChan to constrainChan
  148.           set placeConstrainFlag to 1
  149.         end if
  150.       end if
  151.     else
  152.       if rollOver(the mask of gTrashObject) then
  153.         openTrash(gTrashObject)
  154.       else
  155.         closeTrash(gTrashObject)
  156.       end if
  157.     end if
  158.   end if
  159.   puppetTempo(60)
  160. end
  161.  
  162. on stickerHandler me
  163.   set dragChan to 46
  164.   set currentLayer to the clickOn - firstStickerChan + 1
  165.   set bmap to the castNum of sprite the clickOn
  166.   set boundRect to getBoundRect(bmap, bgChan)
  167.   set dragStickerCastPos to getAt(getAt(stickerList, currentLayer), 4)
  168.   deleteAt(stickerList, currentLayer)
  169.   set the rect of sprite constrainChan to boundRect
  170.   set the castNum of sprite dragChan to bmap
  171.   set the locH of sprite dragChan to the locH of sprite the clickOn
  172.   set the locV of sprite dragChan to the locV of sprite the clickOn
  173.   set the locH of sprite the clickOn to 1000
  174.   updateStage()
  175.   set the constraint of sprite dragChan to constrainChan
  176.   animateSprite(dragChan, point(the mouseH, the mouseV), 3)
  177.   set dragFlag to 1
  178.   hideAllActors()
  179.   add(gActorList, me)
  180. end
  181.  
  182. on clickWhileDragging me
  183.   if placeFlag = 1 then
  184.     if sprite dragChan within bgChan then
  185.       set bmap to the castNum of sprite dragChan
  186.       add(stickerList, [bmap, the locH of sprite dragChan, the locV of sprite dragChan, dragStickerCastPos])
  187.       set stickerChannel to firstStickerChan + count(stickerList) - 1
  188.       set the castNum of sprite stickerChannel to bmap
  189.       set the locH of sprite stickerChannel to the locH of sprite dragChan
  190.       set the locV of sprite stickerChannel to the locV of sprite dragChan
  191.       set the constraint of sprite dragChan to 0
  192.       removeSprite(dragChan)
  193.       updateStage()
  194.       giveAward(gAwardsObject, "MakeAscene")
  195.       set whichSong to getAt(stickerSongList, dragStickerCastPos)
  196.       if whichSong <> #x then
  197.         if getPos(playList, whichSong) = 0 then
  198.           add(playList, whichSong)
  199.         end if
  200.       end if
  201.     else
  202.       if sprite dragChan intersects bgChan then
  203.         set overlapFlag to 1
  204.       end if
  205.       if the mouseV < (the top of sprite bgChan + 50) then
  206.         set destPoint to point(the mouseH, -100)
  207.       else
  208.         if the mouseV > (the bottom of sprite bgChan - 50) then
  209.           set destPoint to point(the mouseH, 580)
  210.         else
  211.           if the mouseH > 320 then
  212.             set destPoint to point(740, the mouseV)
  213.           else
  214.             set destPoint to point(-100, the mouseV)
  215.           end if
  216.         end if
  217.       end if
  218.       set the constraint of sprite dragChan to 0
  219.       animateSprite(dragChan, destPoint, 3)
  220.       removeSprite(dragChan)
  221.       updateStage()
  222.     end if
  223.     set placeConstrainFlag to 0
  224.     set placeFlag to 0
  225.   else
  226.     add(stickerList, [the castNum of sprite dragChan, the locH of sprite dragChan, the locV of sprite dragChan, dragStickerCastPos])
  227.     set the constraint of sprite dragChan to 0
  228.     removeSprite(dragChan)
  229.     drawStickers(me, currentLayer)
  230.     updateStage()
  231.   end if
  232.   set dragFlag to 0
  233.   set gActorList to []
  234.   showAllActors()
  235. end
  236.  
  237. on newSticker me, choice
  238.   set dragFlag to 1
  239.   set placeFlag to 1
  240.   set dragChan to 48
  241.   set bmap to firstColorSticker + choice
  242.   set the castNum of sprite dragChan to bmap
  243.   set currentBoundRect to getBoundRect(bmap, bgChan)
  244.   set the rect of sprite constrainChan to getBoundRect(firstColorSticker + choice, 0)
  245.   updateStage()
  246.   set the constraint of sprite dragChan to constrainChan
  247.   set dragStickerCastPos to choice
  248.   hideAllActors()
  249.   add(gActorList, me)
  250. end
  251.  
  252. on drawStickers me, firstLayer, offset
  253.   repeat with x = firstLayer to count(stickerList)
  254.     set stickerData to getAt(stickerList, x)
  255.     set channel to x + firstStickerChan - 1
  256.     set the castNum of sprite channel to getAt(stickerData, 1) + offset
  257.     set the locH of sprite channel to getAt(stickerData, 2)
  258.     set the locV of sprite channel to getAt(stickerData, 3)
  259.   end repeat
  260. end
  261.  
  262. on trashClick me
  263.   startBuffering()
  264.   if (placeFlag <> 1) and dragFlag then
  265.     set the constraint of sprite dragChan to 0
  266.     animateSprite(dragChan, the location of gTrashObject, 5)
  267.     removeSprite(dragChan)
  268.     set dragFlag to 0
  269.     closeTrash(gTrashObject)
  270.     repeat with x = 1 to count(stickerList) + 1
  271.       set the locH of sprite (firstStickerChan + x - 1) to 1000
  272.     end repeat
  273.     drawStickers(me, 1)
  274.     updateStage()
  275.     set whichSong to getAt(stickerSongList, dragStickerCastPos)
  276.     if whichSong <> #x then
  277.       set songStillNeeded to 0
  278.       repeat with sticker in stickerList
  279.         set existingSong to getAt(stickerSongList, getAt(sticker, 4))
  280.         if existingSong = whichSong then
  281.           set songStillNeeded to 1
  282.           exit repeat
  283.         end if
  284.       end repeat
  285.       if songStillNeeded = 0 then
  286.         deleteAt(playList, getPos(playList, whichSong))
  287.       end if
  288.     end if
  289.     showAllActors()
  290.   else
  291.     if (count(stickerList) > 0) and not objectp(gRollAnimButton) then
  292.       if placeFlag <> 1 then
  293.         openTrash(gTrashObject)
  294.         repeat with x = 1 to count(stickerList)
  295.           set channel to x + firstStickerChan - 1
  296.           removeSprite(channel)
  297.         end repeat
  298.         updateStage()
  299.         set playList to []
  300.         set stickerList to []
  301.         closeTrash(gTrashObject)
  302.       end if
  303.     end if
  304.   end if
  305.   flushBuffer()
  306. end
  307.  
  308. on playSongs me
  309.   hideActor(musicButObject)
  310.   set songTitleList to []
  311.   repeat with song in playList
  312.     add(songTitleList, getAt(songList, song))
  313.   end repeat
  314.   set songPath to gCDpath & "SOUND" & gFileSep & "SONGS" & gFileSep
  315.   set gMusicObject to birth(script "Music Parent", me, songTitleList, songPath)
  316.   add(gActorList, gMusicObject)
  317.   set the mouseDownScript to "stopSound( gSceneObject )"
  318. end
  319.  
  320. on stopSound me
  321.   sound stop 1
  322.   set the mouseDownScript to EMPTY
  323.   clearActor(gMusicObject)
  324.   set gMusicObject to EMPTY
  325.   dontPassEvent()
  326.   showAllActors()
  327. end
  328.  
  329. on saveScene me
  330.   set sceneDataString to EMPTY
  331.   appendData(me, currentBG)
  332.   appendData(me, count(stickerList))
  333.   if count(stickerList) > 0 then
  334.     repeat with sticker in stickerList
  335.       repeat with x = 1 to 4
  336.         appendData(me, getAt(sticker, x))
  337.       end repeat
  338.     end repeat
  339.     appendData(me, count(playList))
  340.     repeat with song in playList
  341.       appendData(me, song)
  342.     end repeat
  343.   end if
  344.   set returnString to sceneDataString
  345.   set sceneDataString to EMPTY
  346.   return returnString
  347. end
  348.  
  349. on loadScene me, index
  350.   set dataCounter to index
  351.   set currentBG to readData(me)
  352.   set stickerList to []
  353.   set stickerQuantity to readData(me)
  354.   if stickerQuantity > 0 then
  355.     repeat with x = 1 to stickerQuantity
  356.       set sticker to []
  357.       repeat with y = 1 to 4
  358.         add(sticker, readData(me))
  359.       end repeat
  360.       add(stickerList, sticker)
  361.     end repeat
  362.     set songQuantity to readData(me)
  363.     set playList to []
  364.     repeat with x = 1 to songQuantity
  365.       set song to readData(me)
  366.       add(playList, song)
  367.     end repeat
  368.   end if
  369.   return dataCounter
  370. end
  371.  
  372. on appendData me, datum
  373.   set sceneDataString to sceneDataString & string(datum) & ","
  374. end
  375.  
  376. on readData me
  377.   set datum to value(item dataCounter of the dataString of gMenuObject)
  378.   set dataCounter to dataCounter + 1
  379.   return datum
  380. end
  381.  
  382. on goMenu me, buttonObject
  383.   if dragFlag <> 1 then
  384.     set musicButObject to EMPTY
  385.     makeButtonJump(buttonObject)
  386.     unpuppetAll()
  387.     puppetPalette("ScenePal", 60)
  388.     go("Grass")
  389.     clearAllActors()
  390.     unLoadCast()
  391.     go(the frame + 1)
  392.     goLocationMap()
  393.   end if
  394. end
  395.  
  396. on help me, buttonObject
  397.   birth(script "Help Parent", buttonObject, #MakeAscene)
  398. end
  399.